<!DOCTYPE html>

<html lang="en">

<html lang="en" class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>新增仲裁员</title>
    <header th:replace="header::html"></header>
    <link th:href="@{/xadmin/lib/layui/css/layui.css}" rel="stylesheet" type="text/css"/>
    <script th:src="@{/xadmin/lib/layui/layui.js}" type="text/javascript"></script>
</head>
<body>
<div class="x-body" style="margin-left:30%;width: 50%;padding-top: 7%">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="L_uaccount" class="layui-form-label">
                <span class="x-red">*</span>账号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_uaccount"  name="uaccount" lay-verify="uaccount"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>将会成为您唯一的账号,长度为6-12个数字
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">
                <span class="x-red">*</span>密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="L_pass"  name="upassword" lay-verify="pass"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                只能输入6-16个字母、数字、下划线
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">
                <span class="x-red">*</span>确认密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="L_pass2"  name="upassword2" lay-verify="pass"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                只能输入6-16个字母、数字、下划线
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_uname" class="layui-form-label">
                <span class="x-red">*</span>用户名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_uname"  name="uname" required="" lay-verify="uname"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                长度3-12
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_telephone" class="layui-form-label">
                <span class="x-red">*</span>手机
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_telephone"  name="uphone" required=""
                       lay-verify="telephone" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                11位标准手机号
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <input type="radio" name="usex" value="男" title="男" checked="true">
                <input type="radio" name="usex" value="女" title="女">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">地址</label>
            <div class="layui-input-inline">
                <input type="text" name="uaddress" lay-verify="uaddress" autocomplete="off" placeholder="请输入地址" class="layui-input" style="width: 70%">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" lay-filter="add" lay-submit="">
                增加
            </button>
        </div>
    </form>
</div>
<script>
	layui.use(['form','layer','jquery'], function () {
		var form = layui.form,
			$ = layui.jquery,
            layer = layui.layer;

		//自定义验证规则
		form.verify({
			uname: [/^.{3,12}$/ , '昵称必须3到12位']
			,telephone: [/^1[3456789]\d{9}$/, '电话号码标准手机号必须为纯数字']
			,pass: [/^(\w){6,16}$/,'只能输入6-16个字母、数字、下划线']
			,uaddress: [/^.{3,30}$/, '请输入正确的地址，限制3-30个字符']
			,uaccount: [/^\d{6,12}$/, '账号限制6-12个数字']
		});

		//监听提交
		form.on('submit(add)', function (data) {
			if (verifyPass()) {
				$.ajax({
					url: "/api-back/arbitration/addArbitration",
					type: "POST",
					data: data.field,
					dataType: 'json',
					success: function (result) {
						if (result.code == 500 || result.code == 5000100 || result.code == 5000101) {
							layer.alert(result.msg);
						} else {
							layer.alert("新增成功", {icon: 6}, function () {
								xadmin.close();
								window.parent.location.reload();
							});
						}
					}
				});
			} else {
				layer.msg("两次密码不一致")
			}
			return false;
		});

	});

	function verifyPass() {
        var p1=$("#L_pass").val();
        var p2=$("#L_pass2").val();
		if (p1 === p2) {
			return true
		} else {
			return false
		}
	}
</script>

</body>


